package com.tzy.note.base.jvm;

public class Car {
    public static void main(String[] args) {
        //类是模板，对象是具体的

        //new出对象
        Car car1 = new Car();
        Car car2 = new Car();
        Car car3 = new Car();
        //获取类对象的hashCode,hashCode不同表示对象不同
        System.out.println(car1.hashCode()); //1163157884
        System.out.println(car2.hashCode()); //1956725890
        System.out.println(car3.hashCode()); //356573597

        //获取对象的类(模板),类的hashCode不同表示类模板不同
        Class<? extends Car> car1Class = car1.getClass();
        Class<? extends Car> car2Class = car1.getClass();
        Class<? extends Car> car3Class = car1.getClass();
        System.out.println(car1Class.hashCode()); //460141958
        System.out.println(car2Class.hashCode()); //460141958
        System.out.println(car3Class.hashCode()); //460141958

        //获取类的加载器
        ClassLoader classLoader = car1Class.getClassLoader();
        System.out.println(classLoader); //sun.misc.Launcher$AppClassLoader@18b4aac2 -->AppClassLoader
        System.out.println(classLoader.getParent()); //sun.misc.Launcher$ExtClassLoader@677327b6 -->ExtClassLoader
        System.out.println(classLoader.getParent().getParent()); //null -->1.不存在 2.java程序获取不到

    }
}
